package by.grsu.epam.dao.entitiesdao.impl;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import by.grsu.epam.dao.GenericDAOImpl;
import by.grsu.epam.dao.entitiesdao.UserRoleDAO;
import by.grsu.epam.domain.user.UserRole;

@Repository
public class UserRoleDAOImpl extends GenericDAOImpl<UserRole, Long> implements UserRoleDAO {
	
	@Override
	public UserRole findByAuthority(String auth) {
		Criteria cr = getSession().createCriteria(UserRole.class);
		cr.add(Restrictions.like("authority", auth));
		
		return (UserRole) cr.uniqueResult();
	}

}
